function fsb_show_design(sandbox,ropts)

% FSB - DEV : Show hemodynamics design
%
% EXAMPLE:
% fsb_show_design(sandbox,ropts)
%
% INPUT:
% ropts: processing options with the fields
%       .srt : Analysis level
% sandbox: experiment struct
%
% OUTPUT:
% Plot of experiment design
%
% CALLED BY:
% fsb_SPM.m
%
% NOTES:
% in development
%
% Steffen Stoewer 050111
%
%$ Revision 0.1
%~~~~~~~~~~~~~~~~~~~~~~~~~~~

%~~~~~~~~~~~~~~~~~~~~~~~~~~~
% determine number of sessions
%~~~~~~~~~~~~~~~~~~~~~~~~~~~

sessionnum = unique(sandbox.intrial(:,ropts.srt));
sessionnum = size(sessionnum,1);

%~~~~~~~~~~~~~~~~~~~~~~~~~~~
% reduce hemodynamics size, currently to first three predictors
%~~~~~~~~~~~~~~~~~~~~~~~~~~~

sandbox.hemodynamics(:,4:end) = [];
hemodynamics = sandbox.hemodynamics;
hemodynamics(:,size(sandbox.hemodynamics,2)*sessionnum+1) = 0;
hemodynamics(:,end) = [];

%~~~~~~~~~~~~~~~~~~~~~~~~~~~
% go over trials
%~~~~~~~~~~~~~~~~~~~~~~~~~~~

y = 0;
for x = 1:max(sandbox.intrial(:,ropts.srt));

    otto = find (sandbox.intrial(:,ropts.srt)==x);
    if isempty(otto)
        disp(['No data for trial ' num2str(x)])
    else

        shemodynamics=hemodynamics(otto,:);
        shemodynamics = circshift(shemodynamics,[0 y*size(sandbox.hemodynamics,2)]);
        hemodynamics(otto,:) = shemodynamics;
        y = y+1;

    end
end
test = max(hemodynamics);

%~~~~~~~~~~~~~~~~~~~~~~~~~~~
% set up design matrix figure
%~~~~~~~~~~~~~~~~~~~~~~~~~~~

designmatrix = figure(1111);
set(designmatrix,'Visible','on','Position',[600,20,350,750],'Resize','off','Toolbar','none','MenuBar','none','NumberTitle','off','Name','Design Matrix');
set(designmatrix,'Name','Design matrix');
t = colormap(gray);
t = flipud(t);
if find(test==0)>1
    clf;
    axis off;
    emptytrial= find(test==0);
    text(0,0.4,'Design matrix will not work')
    text(0,0.2,['Bad sessions: ' num2str(ceil(emptytrial/3))])

else
    imagesc(hemodynamics);colormap(t);
end
axis tight;
ylabel('time (img)');
xlabel('Regressor number');
Title('Design matrix');
end
